package com.mashibing.juc.c_024_FromVectorToQueue;

import java.util.Vector;

/**
 * @author: Yuanzt
 * @Date: 2021/4/1
 */
public class TicketSeller2 {

    static Vector<String> tickets = new Vector<>();

    static {
        for (int i = 0; i < 1000; i++) tickets.add("票号："+i);
    }

    public static void main(String[] args) {
        for (int i = 0; i < 10; i++) {
            new Thread(()->{
                while (tickets.size()>0){
                    try {
                        Thread.sleep(10);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println("销售了："+tickets.remove(0));
                }
            }).start();
        }
    }

}
